<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
if($_RQ['op']=='get'){
	$item=$this->plugin_setting('saleset');
	$return['item']=$item;
	$htmls=array(
		'type'=>'edit',
		'post'=>'set',
		'desc'=>'满额包邮',
		'edit'=>array(
			array('type'=>'switch','name'=>'baoyou_status','title'=>'启用满额包邮？','help'=>'这里是总开关！'),
			array('type'=>'string','name'=>'baoyou_man','title'=>'默认单笔订单满（元）包邮','show'=>array('baoyou_status'=>1)),
			array('type'=>'switch','name'=>'baoyou_levelstatus','title'=>'会员独立满额包邮','help'=>'开启会员独立包邮，优先上面的【满额包邮】'),
			array('type'=>'array','name'=>'baoyou_levelset','add_tip'=>'添加一个包邮设置','title'=>'包邮设置',
				'list'=>array(
						array('type'=>'unitstring','unit'=>'元','name'=>'manfee','title'=>'单笔订单满（元）'),
						array('name'=>'level_id','title'=>'会员等级','type'=>'select','options'=>'levels'),				
				),
				'details'=>array(
						array('type'=>'unitstring','unit'=>'元','name'=>'manfee','title'=>'单笔订单满（元）'),
						array('name'=>'level_id','title'=>'会员等级','type'=>'select','options'=>'levels'),
				)
			),
		)
	);
	$return['levels']=$this->getall('member_level',array('merchid'=>0,'uniacid'=>$_SESSION['uniacid']),array('id','title'),'id');
	$return['levels']['0']=array('id'=>0,'title'=>'默认等级');
	$return['htmls']=$htmls;	
	exi($return);
}
if($_RQ['op']=='set'){
	$post=get_postdata();
	if($post['baoyou_status'] && !$post['baoyou_man']){
		exi('请设置满额数字！','error');
	}
	$this->plugin_setting('saleset',$post);
	exi('设置成功');
}